﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JsonClient.aspx.cs" Inherits="Skynet.WebSite.Demos.JsonClient" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript">
    </script>
</head>
<body>
    <form id="form1" runat="server">

    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference  Path="http://localhost:10001/SkynetLibraryJson.svc/js" />
            </Scripts>
        </asp:ScriptManager>
        <script type="text/javascript">
            function generateGuid() {
                var result, i, j;
                result = '';
                for (j = 0; j < 32; j++) {
                    if (j == 8 || j == 12 || j == 16 || j == 20)
                        result = result + '-';
                    i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
                    result = result + i;
                }
                return result
            }
            var operation = generateGuid();
            function WriteMethodAudit() {
                var id = generateGuid();
                var application = "A3FAB158-90E6-44C9-B716-241F97E82ECF";
                ISkynetLibraryJson.RegisterMethodInterceptor(id,'Skynet', application,operation, "WebSite", "JsonClient", "TestMethod", Callback);                                   
            }
            function GetMethodAuditInfo() {
                ISkynetLibraryJson.GetMethodAuditInfo(EndGetMethodAuditInfo);
            }
            function EndGetMethodAuditInfo(result) {
                $.each(result, function (i, item) { $("#reslist").append('<li>'+ item.Method + '</li>'); ; return true; });                
            }
            function Callback(result) {
                alert(result);
            }

        </script>
        <input id="Button1" type="button" value="button" onclick="return GetMethodAuditInfo();" />
        <div id="result">
        </div>
        <ul id="reslist">
        </ul>        
        Is [] an Array? <b></b>
    </div>
    </form>
</body>
</html>
